class Solution:
    def findGoodStrings(self, n: int, s1: str, s2: str, evil: str) -> int:
        def get_26(s):
            n = len(s) - 1
            ans = 0
            for i in s:
                ans += (ord(i) - 97 ) * (26**n)
                n -= 1
            return ans
        
        ans = 0 # 删掉出现在第一位，出现在第二位
        a = get_26(s2)-get_26(s1) +1
        for i in range(n-len(evil)+1):
            # eval_value =get_26(evil + "z"* (n - len(evil)-i))
            # a = get_26(s2) - eval_value
            # b =  get_26(evil + "a"* (n - len(evil)-i)) - get_26(s1)
            # print(a,b)
            
            max = get_26(evil + "z"* (n - len(evil)-i))
            min = get_26(evil + "a"* (n - len(evil)-i))
            print(max, min)
            ans += max - min + 1
        print(ans)
        print("res=", a-ans)

if __name__ == "__main__":
    n = 2
    s1 = "aa"
    s2 = "da"
    evil = "b"
    Solution().findGoodStrings(n ,s1, s2, evil) == 51